package org.openehealth.ipf.tutorials.xds.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.openehealth.ipf.tutorials.xds.dto.RetrieveDTO;
import org.openehealth.ipf.tutorials.xds.result.ResponseResult;
import org.openehealth.ipf.tutorials.xds.service.Iti43ClientService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.net.MalformedURLException;

/**
 * @author bovane bovane.ch@gmial.com
 * @create 2024/7/26
 */

@Slf4j
@RestController
@RequestMapping("/ihe/xds")
@RequiredArgsConstructor
@Api(tags = "XDS-Iti43取文档内容")
public class Iti43ClientController {

    private final Iti43ClientService iti43ClientService;

    @ApiOperation(value = "ITI41-文档提供与注册")
    @ApiOperationSupport(order = 1)
    @PostMapping(value = "iti43", consumes = "application/json")
    public ResponseResult iti43RetrieveDocument(@RequestBody RetrieveDTO retrieveDTO) throws IOException {
        String retrievedDocument = this.iti43ClientService.retrieveDocument(retrieveDTO);
        return ResponseResult.success(retrievedDocument);
    }
}
